const multer = require("multer")
const fs = require("fs")
exports.create = (router) => {
  router.get("/image/download", multer({ dest: "upload" }).single("image"),(req, res) => {
      try {
        const filePath = `upload/image/${req.query.fileName}`
        if (fs.existsSync(filePath)) {
            res.download(`upload/image/${req.query.fileName}`);
        } else {
            res.status(400).send({
                massage: filePath,
              })
            }
      } catch (error) {
        res.status(400).send({
          massage: false,
        })
    }
}
  )
}
